<?php
return [
    'name' => 'YiiCenter',
    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
    'extensions' => require (__DIR__ . '/../../vendor/yiisoft/extensions.php'),
    'sourceLanguage' => 'en-US',
    'language' => 'zh-CN',
    'timeZone' => 'Asia/Shanghai',
    'bootstrap' => [
        'log'
    ],
    'components' => [
        'modularityService' => [
            'class' => 'common\modules\modularity\ModularityService',
        ],
        'storageService' => [
            'class' => 'common\modules\storage\StorageService',
        ],
        'systemService' => [
            'class' => 'common\modules\system\SystemService',
        ],
        'authManager' => [
            'class' => 'yii\rbac\DbManager',
            'itemTable' => '{{%rbac_auth_item}}',
            'itemChildTable' => '{{%rbac_auth_item_child}}',
            'assignmentTable' => '{{%rbac_auth_assignment}}',
            'ruleTable' => '{{%rbac_auth_rule}}'
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache'
        ],
        'commandBus' => [
            'class' => '\trntv\tactician\Tactician',
            'commandNameExtractor' => '\League\Tactician\Handler\CommandNameExtractor\ClassNameExtractor',
            'methodNameInflector' => '\League\Tactician\Handler\MethodNameInflector\HandleInflector',
            'commandToHandlerMap' => [
                'common\commands\command\SendEmailCommand' => '\common\commands\handler\SendEmailHandler',
            ]
        ],
        'formatter' => [
            'class' => 'yii\i18n\Formatter',
            'dateFormat' => 'yyyy-mm-dd',
            'datetimeFormat' => 'yyyy-mm-dd hh:mm:ss',
            'decimalSeparator' => ',',
            'thousandSeparator' => ' ',
            'currencyCode' => 'CNY'
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                'db' => [
                    'class' => 'yii\log\DbTarget',
                    'levels' => [
                        'error',
                        'warning'
                    ],
                    'except' => [
                        'yii\web\HttpException:*',
                        'yii\i18n\I18N\*'
                    ],
                    'prefix' => function ()
                    {
                        $url = ! Yii::$app->request->isConsoleRequest ? Yii::$app->request->getUrl() : null;
                        return sprintf('[%s][%s]', Yii::$app->id, $url);
                    },
                    'logVars' => [],
                    'logTable' => '{{%system_log}}'
                ]
            ]
        ],
        'i18n' => [
            'translations' => [
                'app' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@common/messages'
                ],
                 /*
                 '*'=> [
                     'class' => 'yii\i18n\PhpMessageSource',
                     'basePath'=>'@common/messages',
                     'fileMap'=>[
                         'common'=>'common.php',
                         'backend'=>'backend.php',
                         'frontend'=>'frontend.php',
                     ],
                     'on missingTranslation' => ['\backend\modules\i18n\Module', 'missingTranslation']
                 ],
                  */
                 //Uncomment this code to use DbMessageSource
                 '*' => [
                    'class' => 'yii\i18n\DbMessageSource',
                    'sourceMessageTable' => '{{%i18n_source_message}}',
                    'messageTable' => '{{%i18n_message}}',
                    'enableCaching' => YII_ENV_DEV,
                    'cachingDuration' => 3600,
                    'on missingTranslation' => [
                        '\common\modules\i18n\backend\Module',
                        'missingTranslation'
                    ]
                ]
            ]
        ],
        /*
        'fileStorage' => [
            'class' => 'common\modules\storage\components\FileStorage',
            'baseUrl' => '@storageUrl/uploads',
            'filesystem' => [
                'class' => 'common\modules\storage\filesystem\LocalFlysystemBuilder',
                'path' => '@storage/web/uploads'
            ],
            'as log' => [
                'class' => 'common\modules\storage\behaviors\FileStorageLogBehavior',
                'component' => 'fileStorage'
            ]
        ],
        */
        'fileStorage' => [
            'class' => 'common\modules\storage\components\QiniuStorage',
            'filesystem' => [
                'class' => 'common\modules\storage\filesystem\QiniuFlysystemBuilder',
            ],
            'as log' => [
                'class' => 'common\modules\storage\behaviors\FileStorageLogBehavior',
                'component' => 'fileStorage'
            ]
        ],
        'keyStorage' => [
            'class' => 'common\modules\storage\components\KeyStorage'
        ],
        'urlManagerApi' => \yii\helpers\ArrayHelper::merge([
            'hostInfo' => Yii::getAlias('@apiUrl')
        ], require (Yii::getAlias('@api/config/_urlManager.php'))),
        'urlManagerBackend' => \yii\helpers\ArrayHelper::merge([
            'hostInfo' => Yii::getAlias('@backendUrl')
        ], require (Yii::getAlias('@backend/config/_urlManager.php'))),
        'urlManagerFrontend' => \yii\helpers\ArrayHelper::merge([
            'hostInfo' => Yii::getAlias('@frontendUrl')
        ], require (Yii::getAlias('@frontend/config/_urlManager.php'))),
        'urlManagerStorage' => \yii\helpers\ArrayHelper::merge([
            'hostInfo' => Yii::getAlias('@storageUrl')
        ], require (Yii::getAlias('@storage/config/_urlManager.php')))
    ]
];
